﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XBLIGUK2011Talk2.PostProcessing
{
    public class LightSceneMask : BasePostProcess
    {
        public Vector3 Position;

        public LightSceneMask(Game game, Vector3 position) : base(game)
        {
            Position = position;
        }

        public override void Draw(GameTime gameTime)
        {
            if (effect == null)
                effect = Game.Content.Load<Effect>("Shaders/PostProcessing/LightSceneMask");

            effect.CurrentTechnique = effect.Techniques["LightSourceSceneMask"];
            effect.Parameters["lightPosition"].SetValue(Position - camera.Position);
            effect.Parameters["matVP"].SetValue(camera.View * camera.Projection);
            effect.Parameters["matInvVP"].SetValue(Matrix.Invert(camera.View * camera.Projection));
            effect.Parameters["halfPixel"].SetValue(HalfPixel);
            effect.Parameters["depthMap"].SetValue(DepthBuffer);            

            base.Draw(gameTime);
        }
    }
}
